<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>相册h上传</title>
<script type="text/javascript" src="multifile_compressed.js"></script>
</head>
<body style="background:#e6e6e6;margin:0px;padding:0px;">
<?php 
if(isset($_POST['act']) && $_POST['act']=='r'){
	$filwj=(isset($_POST['lxs']) && $_POST['lxs']=='jdzt')?"jdzt_pic":"zcbz_pic";
	echo "<div id=loading><img src=\"clocks.gif\">图片上传中...</div>";
	$na="";
	for( $i=0; $i<10; $i++){
		if(!empty($_FILES['file_'.$i]['name'])){
			$rnd = mt_rand(10, 99);
			$filename = uniqid().$rnd;
			$savename=$filename.strtolower(strstr($_FILES['file_'.$i]['name'], '.'));
			$s_pic= dirname(dirname(__FILE__))."/upload/photo/".$savename;
			if($_FILES['file_'.$i]['size']<1000000){
				if(move_uploaded_file($_FILES['file_'.$i]['tmp_name'],$s_pic)){
				if( $i==0 ){
					$na = $savename;
				}else{
					$na .= "|$savename";
				}
				echo "<script type='text/javascript'>document.getElementById('loading').style.visibility='hidden';
					window.opener.document.getElementById('up_preview').innerHTML += '<li><img src=\"upload/photo/$savename\"/></li>';
					</script>";
					@unlink($_FILES['file_'.$i]['name']);
				}
			}else{ echo "图片太大"; }  
		}else{
			echo "<script type='text/javascript'>
			window.opener.document.getElementById('photo_data').value = '$na' ;
			//alert('".$i."张图片上传成功！');
			window.close();</script>";	
			break;
		}
	}
}else{
?>
<div style="maring:5px auto;">
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method = "post">
	<!-- The file element -- NOTE: it has an ID -->
	<input id="my_file_element" type="file" name="file">
	<input type="submit" value="上传">
	<input type="hidden" name="act" value="r">
	<input type="hidden" name="lxs" value="<?php echo $_GET['lxs'];?>">
</form>
</div>
<div>Files:</div>
<!-- This is where the output will appear -->
<div id="files_list" style="padding:5px; "></div>
<script>
	<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
	var multi_selector = new MultiSelector( document.getElementById( 'files_list' ),8);
	<!-- Pass in the file element -->
	multi_selector.addElement( document.getElementById( 'my_file_element' ) );
</script>
<?php }?>
</body>
</html>